package com.ling.map
{
	import com.ling.denfind.EditorDfined;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	public class BgGrid extends Sprite
	{
		private var bmp:Bitmap;
		
		private var _type:uint;
		
		private var _column:int;
		private var _row:int;
		
		
		
		public function BgGrid()
		{
			super();
			
			this.graphics.lineStyle(1,0,0.1);
			this.graphics.beginFill(0x000000,0.1);
			this.graphics.drawRect(0,0,EditorDfined.GRID_SIZE_W,EditorDfined.GRID_SIZE_H);
			this.graphics.endFill();
			
			bmp = new Bitmap();
			addChild(bmp);
		}
		
		public function set column(v:int):void
		{
			_column = v;
			this.x = EditorDfined.GRID_SIZE_W*v;
			
		}
		public function set row(v:int):void
		{
			_row = v;
			this.y = EditorDfined.GRID_SIZE_H*v;
		}
		
		public function get column():int
		{
			return _column;
		}
		public function get row():int
		{
			return _row;
		}
		
		public function set type(v:uint):void
		{
			_type = v;
			bmp.bitmapData = BgGridStyle.getBmd(v);
			bmp.width = EditorDfined.GRID_SIZE_W;
			bmp.height = EditorDfined.GRID_SIZE_H;
		}
		
		public function getXML():XML
		{
			return <grid column={_column} row={_row} type={_type}/>;
		}
	}
}